Fixing NullReferenceException issue with SqlDataAdapter#3857
Fixing NullReferenceException issue with SqlDataAdapter#3857cheenamalhotra merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a NullReferenceException in SqlDataAdapter when processing batch RPC operations with Always Encrypted. The issue occurs when systemParams is null in batch scenarios where SQL RPC calls don't include system-level parameters.
- Adds null check before accessing
systemParams.Lengthto prevent NullReferenceException - Protects the encryption metadata fetching logic in batch RPC mode from operating on null arrays
- Ensures proper handling of RPC objects created with zero system parameters
| // input parameters start at parameters[1]. parameters[0] is the actual | ||
| // T-SQL Statement. rpcName is sp_executesql. | ||
| if (_RPCList[i].systemParams.Length > 1) | ||
| if (_RPCList[i].systemParams != null && _RPCList[i].systemParams.Length > 1) |
There was a problem hiding this comment.
The null check added here is correct and necessary to prevent NullReferenceException in batch scenarios. However, there doesn't appear to be a test case that covers this specific scenario - batching with Always Encrypted where systemParams could be null. Consider adding a test that exercises this code path to prevent regression.
apoorvdeshmukh
left a comment
There was a problem hiding this comment.
Please open another issue to track the pending testcase for this change.
Since we have a repro for this issue, can you add details about how this change was validated?
Description
This Pull Request addresses issue #3716 by introducing a null check for systemParams, which stores the system-level parameters for SQL RPC (Remote Procedure Call) operations. In batch scenarios, certain SQL RPC calls may not include system parameters, and this change ensures proper handling in such cases.
Issues
#3716